#CompileOpt=  -c -O2 -w1 -I/opt/intel/Compiler/11.1/072/mkl/include/ -I./include/ -DWorkshopPath=\"LOCAL\"
CompileOpt=  -c -O2 -w1 -I/opt/intel/Compiler/11.1/072/mkl/include/ -I./include/ -DWorkshopPath=\"SERVER\"
LinkOpt= -L/usr/local/lib -L/opt/intel/Compiler/11.1/072/mkl/lib/32

object_share = diagnosis.o GenClst_Algorithm.o GenClst_Control.o gsl_app.o HamiForm.o MatAlgebra.o \
parameters.o pulseseq.o

object_core = CCEengine.o Cluster.o Spin.o

object_special = import_data.o interaction_NV.o

exec_cce = NV_cce

logfile = MakeInfo.log
version = Version.log

ObjShareDir = ../obj/share
ObjSpecDir = ../obj/special
ObjCoreDir = ../obj/core
BinDir = ../bin

SrcShareDir = ./source/share
HeadShareDir = ./include/share

SrcCoreDir = ./source/core
HeadCoreDir = ./include/core

SrcSpecDir= ./source/special
HeadSpecDir= ./include/special

#NeedLib = -lgsl -lgslcblas -lmkl_intel -lmkl_intel_thread -lmkl_core -lguide -lpthread
NeedLib = -lgsl -lgslcblas -lmkl_intel_lp64 -lmkl_intel_thread -lmkl_core -lguide -lpthread

VPATH = $(SrcShareDir) : $(SrcCoreDir) : $(SrcSpecDir) \
: $(HeadShareDir) : $(HeadCoreDir) : $(HeadSpecDir) \
: $(ObjShareDir) : $(ObjSpecDir) : $(ObjCoreDir)

#bin
$(BinDir)/MakeInfo: $(BinDir)/$(exec_cce) 
	date > $(BinDir)/$(logfile)
	svn update > $(BinDir)/$(version)

$(BinDir)/NV_cce: $(object_share) $(object_core) $(object_special)
	icpc $(LinkOpt) $(ObjShareDir)/*.o $(ObjCoreDir)/*.o $(ObjSpecDir)/*.o -o $(BinDir)/$(exec_cce) $(NeedLib) 

#core	
$(ObjCoreDir)/CCEengine.o: CCEengine.cpp globalvars.h parameters.h pulseseq.h import_data.h \
material_NV.h interaction_NV.h GenClst_Control.h  HamiForm.h Spin.h Cluster.h 
	icpc $(CompileOpt) $(SrcCoreDir)/CCEengine.cpp -o $(ObjCoreDir)/CCEengine.o

$(ObjCoreDir)/Cluster.o: Cluster.cpp Cluster.h Usrdef.h globalvars.h Spin.h pulseseq.h parameters.h MatAlgebra.h \
HamiForm.h diagnosis.h interaction_NV.h material_NV.h
	icpc $(CompileOpt) $(SrcCoreDir)/Cluster.cpp -o $(ObjCoreDir)/Cluster.o

$(ObjCoreDir)/Spin.o: Spin.cpp Spin.h Usrdef.h globalvars.h Spin.h interaction_NV.h GenClst_Control.h
	icpc $(CompileOpt) $(SrcCoreDir)/Spin.cpp -o $(ObjCoreDir)/Spin.o
		
#comm
$(ObjShareDir)/diagnosis.o: diagnosis.cpp diagnosis.h Usrdef.h globalvars.h 
	icpc $(CompileOpt) $(SrcShareDir)/diagnosis.cpp -o $(ObjShareDir)/diagnosis.o

$(ObjShareDir)/GenClst_Algorithm.o: GenClst_Algorithm.cpp GenClst_Algorithm.h Usrdef.h globalvars.h parameters.h gsl_app.h
	icpc $(CompileOpt) $(SrcShareDir)/GenClst_Algorithm.cpp -o $(ObjShareDir)/GenClst_Algorithm.o

$(ObjShareDir)/GenClst_Control.o: GenClst_Control.cpp GenClst_Control.h GenClst_Algorithm.h Usrdef.h parameters.h globalvars.h
	icpc $(CompileOpt) $(SrcShareDir)/GenClst_Control.cpp -o $(ObjShareDir)/GenClst_Control.o

$(ObjShareDir)/gsl_app.o: gsl_app.cpp gsl_app.h Usrdef.h using_namespace.h
	icpc $(CompileOpt) $(SrcShareDir)/gsl_app.cpp -o $(ObjShareDir)/gsl_app.o		

$(ObjShareDir)/HamiForm.o: HamiForm.cpp HamiForm.h Usrdef.h globalvars.h parameters.h GenClst_Control.h GenClst_Algorithm.h
	icpc $(CompileOpt) $(SrcShareDir)/HamiForm.cpp -o $(ObjShareDir)/HamiForm.o		

$(ObjShareDir)/MatAlgebra.o: MatAlgebra.cpp MatAlgebra.h Usrdef.h using_namespace.h
	icpc $(CompileOpt) $(SrcShareDir)/MatAlgebra.cpp -o $(ObjShareDir)/MatAlgebra.o

$(ObjShareDir)/parameters.o: parameters.cpp parameters.h Usrdef.h using_namespace.h globalvars.h
	icpc $(CompileOpt) $(SrcShareDir)/parameters.cpp -o $(ObjShareDir)/parameters.o

$(ObjShareDir)/pulseseq.o: pulseseq.cpp pulseseq.h Usrdef.h using_namespace.h parameters.h
	icpc $(CompileOpt) $(SrcShareDir)/pulseseq.cpp -o $(ObjShareDir)/pulseseq.o

#Spec
$(ObjSpecDir)/interaction_NV.o: interaction_NV.cpp interaction_NV.h gsl_app.h Usrdef.h using_namespace.h
	icpc $(CompileOpt) $(SrcSpecDir)/interaction_NV.cpp -o $(ObjSpecDir)/interaction_NV.o

$(ObjSpecDir)/import_data.o: import_data.cpp import_data.h Usrdef.h parameters.h globalvars.h material_NV.h
	icpc $(CompileOpt) $(SrcSpecDir)/import_data.cpp -o $(ObjSpecDir)/import_data.o
		
.PHONY: clean
clean:
	-rm -f $(ObjShareDir)/*.o $(ObjSpecDir)/*.o $(ObjCoreDir)/*.o \
$(BinDir)/* $(BinDir)/$(logfile)
